package com.asianrapid.controller.sys;

import com.asianrapid.model.sys.LqrwEntity;
import com.asianrapid.model.sys.LqrzEntity;
import com.asianrapid.model.sys.PageResult;
import com.asianrapid.service.sys.LqrwService;
import com.asianrapid.service.sys.LqrzService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class LqrwController {
    private Logger log = LoggerFactory.getLogger(LqrwController.class);
    @Autowired
    private LqrwService lqrwService;

    /**
     * @Author:lqr @Description:获得所有数据 @Params: @Date: 17:23 2019/8/30
     */
    @GetMapping("/getlqrw")
    public PageResult getall(int pageSize, int page) {
        PageResult pageResult = new PageResult();
        List<LqrwEntity> list = lqrwService.getalllqrw(pageSize, page);
        int total = lqrwService.getCount();
        pageResult.setTotalCount(total);
        pageResult.setData(list);
        return pageResult;
    }

    /**
     * @Description: 下拉列表 @Params: * @param @Date: 17:29 2019/8/30
     */
    @GetMapping("/select")
    public List<LqrwEntity> select() {
        return lqrwService.select();
    }

    /**
     * @Description: 新增 @Params: * @param lqrwEntity @Date: 17:27 2019/8/30
     */
    @PostMapping("/insertlqrw")
    public void insert(@RequestBody LqrwEntity lqrwEntity) {
        lqrwService.insertlqrw(lqrwEntity);
    }

    /**
     * @Description: 修改 @Params: * @param lqrwEntity @Date: 17:27 2019/8/30
     */
    @PutMapping("/updatelqrw")
    public LqrwEntity update(@RequestBody LqrwEntity lqrwEntity) {
        lqrwService.updatelqrw(lqrwEntity);
        return lqrwEntity;
    }

    /**
     * @Description: 回显 @Params: * @param groupId @Date: 17:28 2019/8/30
     */
    @PostMapping("/loadw")
    public LqrwEntity loadw(@RequestBody List<Integer> groupId) {
        return lqrwService.loadw(groupId.get(0));
    }

    /**
     * @Description: 删除 @Params: * @param groupId @Date: 17:28 2019/8/30
     */
    @DeleteMapping("/deletelqrw")
    public List<String> deletelqrw(@RequestBody List<String> groupId) {
        lqrwService.deletelqrw(groupId);
        return groupId;
    }
}
